using System.Reflection;
using System.Diagnostics;

namespace Dida
{
	public static class Animation
	{
		static bool isInitialized = false;

		public static void Init()
		{
			Debug.Assert(!isInitialized, "You shouldn't initialize the Animation module more than once");
			Debug.Assert(Geometry.IsInitialized,"You should call Geometry.Init before you call Animation.Init.");

			Dxml.DidaXml.RegisterComplexParser(typeof(AniSocket<float>),
				typeof(FloatSocketParser));
			Dxml.DidaXml.RegisterComplexParser(typeof(AniSocket<Vector3D>),
				typeof(Vector3DSocketParser));
			Dxml.DidaXml.RegisterComplexParser(typeof(AniSocket<EulerRot>),
				typeof(EulerRotSocketParser));
			Dxml.DidaXml.RegisterComplexParser(typeof(AniSocket<Quaternion>),
				typeof(QuaternionSocketParser));
			Dxml.DidaXml.RegisterComplexParser(typeof(AniSocket<SimpleTransform>),
				typeof(SimpleTransformSocketParser));

			Dxml.DidaXml.ScanAssembly(Assembly.GetExecutingAssembly());
			Dxml.DidaXml.RegisterObjectCompiler("AniSet", typeof(AniSetCompiler));

			isInitialized = true;
		}

		public static void Free()
		{
			isInitialized = false;
		}

		public static bool IsInitialized
		{
			get { return isInitialized; }
		}
	}
}